<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <title>IBMS-Platform</title>
  <script type='text/javascript' src='login/custom/jquery1.7.2.js'></script>
	<link rel='stylesheet' type='text/css' href="login/custom/login.css" />
</head>
<body class="hold-transition login-page">
<div id="a-login-background">
  <img src="login/custom/login.jpg">
</div>
<div class="login-box">
  <div class="login-logo">
    <a class="white"><b class="red">Intelligent Building</b>&nbsp;</a>
  </div>
  <div class="login-title white">Management System</div>
  <div class="login-box-body">
	<div class="login-box-form">
    <div id="login-failed" style="display: none;">Login failed</div>
		<p class="login-box-msg">Sign in to start your session：</p>
		<form id="login-form" method="post" action=prelogin>
		  <div class="form-group has-feedback">
			<input type="text" class="form-control" name="j_username" id="username" placeholder="Username">
		  </div>
		  <div class="row">
			<div class="col-xs-4 col-xs-offset-8">
			  <button type="submit" class="btn btn-success btn-block btn-flat">Sign in</button>
			</div>
		  </div>
		</form>
	</div>
	<div class="toolbar clearfix" style="text-align: right;padding-right: 20px;">
		&copy;&nbsp;IBMS
	</div>
  </div>
</div>
<script>
  function getQueryVariable(variable) {
    const query = window.location.search.substring(1);
    const vars = query.split("&");
    for (let i=0;i<vars.length;i++) {
      const pair = vars[i].split("=");
      if(pair[0] == variable){
        return pair[1];
      }
    }
    return(false);
  }
  $(function() {
    if(getQueryVariable("auth") == "fail") {
      $("#login-failed").css("display", "block");
    }
    if(window !=top){
      top.location.href = location.href;
    }
  });
</script>
</body>
</html>
